#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

int main()
{
    FILE *file = fopen("bite.c","w");
    if(!file){
        perror("fopen error!\n");
        return 1;
    }
    //向文件中写入内容
    const char *data = "linux so easy!\n";
    size_t result = fwrite(data, 1, strlen(data), file);
    
    fclose(file);

    file = fopen("bite.c","r");
    if(!file){
        perror("fopen error!\n");
        return 1;
    }
    //将内容打印到显示屏
    char buffer[1024];
    result = fread(buffer, 1, sizeof(buffer), file);

    printf("%s",buffer);
    fclose(file);

    //将光标移动
    file = fopen("bite.c","r+");
    if(!file){
        perror("fopen error!\n");
        return 1;
    }
    if(fseek(file, 5, SEEK_SET) != 0)
    {
        perror("error fseek!\n");
    }
    char buffer2[100];
    result = fread(buffer2, 1, sizeof(buffer), file);

    printf("%s",buffer2);
    fclose(file);


    return 0;
}
